/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nominalitzacions.domain;

import java.io.FileNotFoundException;
import java.io.IOException;
import nominalitzacions.persistance.TextDataManagerController;

/**
 *
 * @author sonia.sandalinas
 */
public class TextDomainController {

    private VerbalFormsController VFC;
    private LanguageDomainController LDC;
    private TextDataManagerController TDMC;

    public TextDomainController() throws FileNotFoundException, IOException {
        //TPC = new TextPersitanceController();
        //LDC = new LanguageDomainController();
        //TDC = new TextDataController();
    }

    public int[][] whatHighlight(String text) throws IOException {
        LDC = new LanguageDomainController();
        LDC.loadLanguage();
        int i = 0;
        int index = 0;
        String verb = "";
        int[][] hihghlight = new int[text.length()][2];
        while (i < text.length()) {
            int tamVerb = 0;
            System.out.println(i);
            System.out.println(text.charAt(i));
            while ((i < text.length()) &&
                    (((text.charAt(i) >= 'a' && text.charAt(i) <= 'z') ||
                    (text.charAt(i) >= 'A' && text.charAt(i) <='Z')) 
                    || text.charAt(i) == '{' || text.charAt(i) == '}'|| text.charAt(i) =='_')) {
                ++i;
                ++tamVerb;
            }
            System.out.println(i);
            int start = i - tamVerb;
            int end = i;
            System.out.println(start +" "+ end);
            verb = text.substring(start, end);
            verb = verb.toLowerCase();
            if (LDC.searchVerb(verb)) {
                hihghlight[index][0] = start;
                hihghlight[index][1] = end;
                ++index;
            }
            System.out.println(i);
            String s = System.getProperty("line.separator");
            char[] fi = s.toCharArray();

            System.out.println(fi.length);
            //text.replaceAll(s, "\\n");
            while ((i < text.length()) &&
                    ((text.charAt(i) < 'A') || (text.charAt(i) > 'Z' && text.charAt(i) < 'a')
                    || (text.charAt(i) > 'z'))) ++i;
            }

            //System.out.println(i);

        return hihghlight;
    }

    public String openText(String txt){
        TDMC = new TextDataManagerController();
        String text = TDMC.openText(txt);
        return text;
    }
    public void saveText(String text, String path) {
    //    void TDMC.saveTextData(text, path);
    }
}